package cn.cdqf.rabbitmq.controller;


import cn.cdqf.rabbitmq.common.ResultResponse;
import cn.cdqf.rabbitmq.param.RabbitMqParam;
import cn.cdqf.rabbitmq.rabbit.RabbitSender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
public class RabbitController {
    @Autowired
    private RabbitSender rabbitSender;
    /**
     * String message
     * Map properties
     * String exchange
     * String routKey
     */
    @PostMapping(value = "rabbit")
    public ResultResponse send(
            @RequestBody RabbitMqParam rabbitMqParam
            ){

        log.info("来了。。。");
        rabbitSender.send(rabbitMqParam.getMessage()
                , rabbitMqParam.getProperties(), rabbitMqParam.getExchange(), rabbitMqParam.getRoutKey());
        return ResultResponse.success();
    }

}
